<?php

session_start();
require( 'util.php' );

if (is_logged_as_monitor())
{
    validate_action_get( array( 'cid', 'pid' ) );
    $cid = $_GET['cid'];
    $pid = $_GET['pid']; // TODO:
    
    require( 'db.php' );
    
    $sql = "DELETE FROM `comment` WHERE c_id = $cid";
    $result = mysql_query( $sql ) or report_err_and_exit( mysql_error() );
	
    $sql = "UPDATE page SET comment_times = comment_times - 1 WHERE p_id = $pid";
    $result = mysql_query( $sql ) or report_err_and_exit( mysql_error() );
    
    // TODO:
    redirect_and_exit( 'view_page.php?pid=' . $pid, '成功删除了指定评论' );
}
else
{
    report_err_and_exit( '必须以版主的身份登录' );
}

?>